package com.sjgs.gis.config;

import com.sjgs.gis.fs.store.DefaultKVStore;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.sjgs.common.Constants.DN_SID;

@Configuration
@AutoConfigureAfter({DiscoveryClientOptionalArgsConfiguration.class})
public class DataNodeClientLoadBalancerConfiguration {

    /**
     * dataNode KetamaHashLoadBalancer
     * @param discoveryClient
     * @return
     */
    @Bean(value = "dnLoadBalancer")
    KetamaHashLoadBalancer getKetamaHashLoadBalancer(DiscoveryClient discoveryClient, DefaultKVStore kvstore){
        return new KetamaHashLoadBalancer(discoveryClient,kvstore,DN_SID);
    }
}
